class GLTexture
{
public:
    //
    // Options when loading an image to an GLTexture. Use the
    // kGenerateMipmaps option to use OpenGL to generate mipmaps -
    // downsampled images used to improve the quality of texture
    // filtering.
    //
    enum ImageOptions {
        kNone = 0,
        kGenerateMipmaps = 0x1,
    };

    //
    // Create a new GLTexture using the pixel data from the given
    // image (which will be copied in). Use the options to specify
    // whether mipmaps should be generated.
    //
    GLTexture(const Bitmap &bmp,
              ImageOptions options = kGenerateMipmaps);

    //
    // Create an "empty" GLTexture with no image data. You will need
    // to load an image before you can use this texture for
    // rendering.
    //
    GLTexture();

    //
    // Delete an existing GLTexture.
    //
    ~GLTexture();

    //
    // Load image data into the GLTexture. The texture will be
    // resized to match the image as needed. Use the options
    // to specify whether mipmaps should be generated.
    //
    void LoadImageData(const Bitmap &bmp,
                       ImageOptions options = kGenerateMipmaps);

    //
    // Bind this texture for use in subsequent OpenGL drawing.
    //
    void Bind();

    //
    // Un-bind this texture and return to untextured drawing.
    //
    void UnBind();

    //
    // Set the OpenGL texture-filtering mode to use for texture
    // magnification and minification respectively.
    // For example:
    //      SetFilter(GL_LINEAR,
    //                GL_LINEAR_MIPMAP_LINEAR);
    //
    void SetFilter(GLint magFilter, GLint minFilter);

    //
    // Set the OpenGL mode to use for texture addressing in
    // the S and T dimensions respectively.
    // For example:
    //      SetWrap(GL_REPEAT, GL_REPEAT);
    //
    void SetWrap(GLint wrapS, GLint wrapT);

    //
    // Get the width (in pixels) of the image.
    //
    int GetWidth() const { return _width; }

    //
    // Get the height (in pixels) of the image.
    //
    int GetHeight() const { return _height; }

private:
    // Common initialization code, used by all constructors.
    void Initialize();

    // The OpenGL texture id.
    GLuint _texId;

    // The width and height of the image data.
    int _width;
    int _height;
};
